/*
* ============================================================================
*  Name        : example_002.hxx
*  Part of     : Finite state machine examples
*  Description : State machine body
*  Version     : %version: %
*  
*
* ============================================================================
*/
/**
    @code 
    SM_DECLARE
    (
        // Source code name to be passed to create( ) of HelloTheWorld class instance
        HelloTheWorld_002_src,  

        // Class name 
        HelloTheWorld_002       

        // Synchronous execution. start( ) does not exit util state machine is finished
        sync                    
        {
            // All unprocessed in other states events get here. The only mandatory state.
            Exceptions          
            {
                 // 'exit' - predefined action function terminating state machine
                 Ev_Sys_Terminate        exit            nojump  
            }
            // Entry state. All state names are user defined.
            // State life cycle: 'Heart beat interval in ms' and 
            // 'Total Heart beat number' separated by space
            // - trigger Ev_Sys_Heartbeat event every 1000ms
            // - trigger Ev_Sys_LastHeartbeat on last timeout
            // If both are missing - state does not have a timer
            Main  300 2
            {
                // On state entry execute say_hello( ).'nojump' 
                // is a reserved key word, instructing to stay in the state
                Ev_Sys_OnEntry          say_hello       nojump  

                // On first timeout execute say_sea( )
                Ev_Sys_Heartbeat        say_sea         nojump  
                
                // On last timeout execute say_world( )
                Ev_Sys_LastHeartbeat    say_world       nojump  

                // Invoke exit to terminate state machine
                Ev_Sys_LastHeartbeat    exit            nojump  
            }
        } 
    );

    @endcode
 */

SM_DECLARE
(
    // Source code name to be passed to create( ) of HelloTheWorld class instance
    HelloTheWorld_002_src,  

    // Class name 
    HelloTheWorld_002       

    // Synchronous execution. start( ) does not exit util state machine is finished
    sync                    
    {
        // All unprocessed in other states events get here. The only mandatory state.
        Exceptions          
        {
             // Engine shutdown event handler. 
             // 'exit' - predefined action function terminating state machine
             Ev_Sys_Terminate        exit            nojump  
        }
        // Entry state. All state names are user defined.
        // State life cycle: 'Heart beat interval in ms' and 
        // 'Total Heart beat number' separated by space
        // - trigger Ev_Sys_Heartbeat event every 1000ms
        // - trigger Ev_Sys_LastHeartbeat on last timeout
        // If both are missing - state does not have a timer
        Main  300 2
        {
            // On state entry execute say_hello( ).'nojump' 
            // is a reserved key word, instructing to stay in the state
            Ev_Sys_OnEntry          say_hello       nojump  

            // On first timeout execute say_sea( )
            Ev_Sys_Heartbeat        say_sea         nojump  
            
            // On last timeout execute say_world( )
            Ev_Sys_LastHeartbeat    say_world       nojump  

            // Invoke exit to terminate state machine
            Ev_Sys_LastHeartbeat    exit            nojump  
        }
    } 
);
